package com.boco.blch.dispatcher.util;

import java.util.ArrayList;

public class NetworkSegmentUtil {
	
	public static String[] Analyse(String StartIp,String EndIp) {
	    ArrayList<String> ips = new ArrayList<String>();
	    String[] ipfromd = StartIp.split("\\.");
	    String[] iptod = EndIp.split("\\.");
	    int[] int_ipf = new int[4];
	    int[] int_ipt = new int[4];
	    for (int i = 0; i < 4; i++) {
	        int_ipf[i] = Integer.parseInt(ipfromd[i]);
	        int_ipt[i] = Integer.parseInt(iptod[i]);
	    }
	    for (int A = int_ipf[0]; A <= int_ipt[0]; A++) {
	        for (int B = (A == int_ipf[0] ? int_ipf[1] : 0); B <= (A == int_ipt[0] ? int_ipt[1]
	                : 255); B++) {
	            for (int C = (B == int_ipf[1] ? int_ipf[2] : 0); C <= (B == int_ipt[1] ? int_ipt[2]
	                    : 255); C++) {
	                for (int D = (C == int_ipf[2] ? int_ipf[3] : 0); D <= (C == int_ipt[2] ? int_ipt[3]
	                        : 255); D++) {
	                    ips.add(new String(A + "." + B + "." + C + "." + D));
	                }
	            }
	        }
	    }
	    return (String[])ips.toArray(new String[0]);
}
	public static void main(String[] args)
	{
		String ip1="10.10.1.6";
		String ip2="10.9.2.100";
		String[] ip=Analyse(ip1,ip2);
		for(int i=0;i<ip.length;i++)
		{
			System.out.println(ip[i]);
		}
	}
}
